s = input()
mx = 0
if len(s) == 4:
    a = [s[0], s[1], s[2], s[3], s[0 : 2], s[1 : 3], s[2 : 4], s[0 : 3], [1 : 4], s]
    for j in range(len(a)):
        n = int(a[i])
        c = 2
        for i in range(2, n//2+1):
            if n%1 == 0:
                c+=1
        if c == 2  and n != 1:
            mx = max(mx, n)
print(mx)
